﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SSDPNET;
using ATEC.ATDataCoreNET;
using ATEC.ATDataCoreNET.ATObjects;
using SSDPNET.DataCore;

namespace DoModelExample
{
    public enum ViewIndex
    {
        //三视口绑定Scene视口index
        ViewIndex_Horizon = 0,
        ViewIndex_Vertical = 1,
        ViewIndex_Spatial = 2,
        ViewIndex_Cross = 3,
    }
    public enum ShowWhoInScene
    {
        All,            // 所有对象全部显示
        Alignment_Only, // 仅显示路线
    }

    public class ViewManager
    {
        /// <summary>
        /// 激活视口
        /// </summary>
        /// <param name="viewIndex"></param>

        public static void ActiveView(ViewIndex viewIndex)
        {
            IndexedViewSet viewSet = IViewManager.GetActiveViewSet();
            int nCurrentNum = viewSet.GetSelectedView();
            if (nCurrentNum != (int)viewIndex)
            {
                IndexedViewport vp = viewSet.GetViewport((int)viewIndex);
                viewSet.SetSelectedView(vp, true, true);
            }
        }

        /// <summary>
        ///布满视口
        /// </summary>
        public static void FitView()
        {
            IndexedViewSet viewSet = IViewManager.GetActiveViewSet();
            IndexedViewport viewport = viewSet.GetSelectedViewport();

            ATEC.GeometryNET.XRange3d sceneRange;
            ATSceneRef scene = SSDPNET.ScenesFunctions.SceneRefGetActive();

            // 计算当前scen所在的空间范围
            if (viewport.ComputeDisplayedSceneRefRange(out sceneRange, scene, true) != StatusInt.Success)
            {
                return;
            }

            // 将当前视口范围调整到scen所在的空间范围
            if (viewport.ChangeAreaFromFit(sceneRange.Low, sceneRange.High, false, true) != StatusInt.Success)
            {
                return;
            }

            viewport.CenterScrollBar();
            viewport.ForceHealImmediate(500);
        }

    }
}
